/*jslint vars: true, forin:true, sloppy: true*/
/*global angular, probe*/
/*
* takes an array as input and returns an array
* */
probe.filter("translateIns", function () {
	var translateType = ['等待','动作','断言'];
	var translateAction = function (str) {
		switch (str) {
			case 'click':
				return '点击';
			case 'input':
				return '赋值';
			case 'dblclick':
				return '双击';
			default:
				return '动作';
		}
	};

	var getAbst = [
		//0.wait
		function (stmt) {
			return '等待 ' + stmt.BODY.delay + '毫秒';
		},
		//1.action
		function (stmt) {
			var out = translateAction(stmt.BODY.action) + " " +
				stmt.BODY.object + '元素';

			if (stmt.BODY.param !== null && stmt.BODY.param !== undefined) {
				if (stmt.BODY.paramType === 1) {
					out += " 基于字典";
				} else if (stmt.BODY.paramType === 2) {
					out += " 符合正则表达式的字符串";
				} else {
					out += " 值：" + stmt.BODY.param;
				}
			}

			return out;
		},
		//2.assert
		function (stmt) {
			var out = "断言 " + stmt.BODY.exp + '元素 存在';

			if (stmt.BODY.timeout !== undefined) {
				out += " 等待时长：" + stmt.BODY.timeout + '毫秒';
			}

			return out;
		}
	];

	return function (input) {
		angular.forEach(input, function (item) {
			item.ins = translateType[item.TYPE];
			item.abst = getAbst[item.TYPE](item);
		});

		return input;
	};
});